import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LandVO, LandForm, LandQuery } from '@/api/agriculture/land/types';

/**
 * 查询地块列表
 * @param query
 * @returns {*}
 */

export const listLand = (query?: LandQuery): AxiosPromise<LandVO[]> => {
  return request({
    url: '/agriculture/land/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询地块详细
 * @param landId
 */
export const getLand = (landId: string | number): AxiosPromise<LandVO> => {
  return request({
    url: '/agriculture/land/' + landId,
    method: 'get'
  });
};

/**
 * 新增地块
 * @param data
 */
export const addLand = (data: LandForm) => {
  return request({
    url: '/agriculture/land',
    method: 'post',
    data: data
  });
};

/**
 * 修改地块
 * @param data
 */
export const updateLand = (data: LandForm) => {
  return request({
    url: '/agriculture/land',
    method: 'put',
    data: data
  });
};

/**
 * 删除地块
 * @param landId
 */
export const delLand = (landId: string | number | Array<string | number>) => {
  return request({
    url: '/agriculture/land/' + landId,
    method: 'delete'
  });
};
